(function() {

  this.Messages = {
    WriteErrors: function(textErrors) {
      if ((textErrors != null) && textErrors.length) {
        Messages.Clear();
        return _.each(textErrors, function(error) {
          var div;
          if ((error.Key != null) && error.Key.length > 0) {
            div = $("body").find("form").find("input[name=" + error.Key + "], textarea[name=" + error.Key + "], select[name=" + error.Key + "]").closest("fieldset > div");
            if (div.length) {
              div.data("error-message", error.Message);
              return div.addClass("error");
            }
          } else {
            return alertify.error(error.Message);
          }
        });
      }
    },
    WriteSuccessMessage: function(textmessage) {
      return alertify.success(textmessage);
    },
    WriteMessage: function(textmessage) {
      return alertify.log(textmessage);
    },
    Clear: function() {
      return $("#alertify-logs").find("article").remove();
    }
  };

}).call(this);
